const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Warehouse = sequelize.define('Warehouse', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: 'Warehouse name'
  },
  location: {
    type: DataTypes.STRING(200),
    allowNull: false,
    comment: 'Warehouse location/address'
  },
  capacity: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: 'Warehouse capacity (number of items)'
  },
  manager: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: 'Warehouse manager name'
  },
  phone: {
    type: DataTypes.STRING(20),
    allowNull: true,
    comment: 'Contact phone number'
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive', 'maintenance'),
    defaultValue: 'active',
    comment: 'Warehouse status'
  },
  created_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    field: 'created_at'
  },
  updated_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    field: 'updated_at'
  }
}, {
  tableName: 'warehouses',
  timestamps: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at'
});

module.exports = Warehouse;

